//
//  NSObject+CGSIZE.m
//  SG
//
//  Created by FISH on 2018/4/19.
//  Copyright © 2018年 yimindai. All rights reserved.
//

#import "NSObject+CGSIZE.h"

@implementation NSObject (CGSIZE)

- (CGSize)sizeWithString:(NSString *)string font:(UIFont *)font maxWidth:(NSInteger)width
{
    CGRect rect = [string boundingRectWithSize:CGSizeMake(width, 8000)//限制最大的宽度和高度
                                       options:NSStringDrawingUsesLineFragmentOrigin|
                   NSStringDrawingUsesFontLeading|
                   NSStringDrawingTruncatesLastVisibleLine//采用换行模式
                                    attributes:@{NSFontAttributeName: font}//传入的字体字典
                                       context:nil];
    return rect.size;
}

@end
